package br.com.lucasddaniel.merchanmobile.activities;

import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import br.com.lucasddaniel.merchanmobile.R;
import br.com.lucasddaniel.merchanmobile.adapter.PasseiosRelatorioAdapter;
import br.com.lucasddaniel.merchanmobile.bean.PasseioBean;
import br.com.lucasddaniel.merchanmobile.dao.ExcessaoBanco;
import br.com.lucasddaniel.merchanmobile.Controller;

public class Relatorios extends Activity {

    private ListView lvPasseios;
    private PasseiosRelatorioAdapter passeiosAdapter;
    private List<PasseioBean> listPasseios;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_relatorio_passeio);

        try {
            listPasseios = Controller.getInstance().listaPasseios(getApplicationContext());
        } catch (ExcessaoBanco e) {
            e.printStackTrace();
        }
        initializeComponents();
    }

    private void initializeComponents() {
        lvPasseios = (ListView) findViewById(R.id_activity_listar_passeios.listview);
        passeiosAdapter = new PasseiosRelatorioAdapter(getApplicationContext(), R.layout.row_passeio, listPasseios);
        lvPasseios.setAdapter(passeiosAdapter);
        lvPasseios.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
                Intent it = new Intent(Relatorios.this, RelatorioPacotes.class);
                it.putExtra("idPasseio", passeiosAdapter.getItem(position).getId());
                startActivity(it);
            }
        });
    }
}
